package com.ruoyi.flink.util.test;

import org.apache.flink.streaming.api.datastream.DataStreamSource;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;
import com.ruoyi.flink.chapten5.Event;
import com.ruoyi.flink.util.write.MysqlWrite;

/**
 * @Description: 向mysql中写入文件
 * @ClassName: MysqlWriteTest
 * @author syc
 * @date: 2022年5月30日 上午9:38:23
 * 我与春风皆过客,你携秋水揽星河
 */
public class MysqlWriteTest_1 {
	public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment env = StreamExecutionEnvironment.getExecutionEnvironment();
        env.setParallelism(1);
        DataStreamSource<Event> stream = env.fromElements(
                new Event("Mary", "./home", 1000L),
                new Event("Bob", "./cart", 2000L),
                new Event("Alice", "./prod?id=100", 3000L),
                new Event("Alice", "./prod?id=200", 3500L),
                new Event("Bob", "./prod?id=2", 2500L),
                new Event("Alice", "./prod?id=300", 3600L),
                new Event("Bob", "./home", 3000L),
                new Event("Bob", "./prod?id=1", 2300L),
                new Event("Bob", "./prod?id=3", 3300L)
        );
        stream.addSink(new MysqlWrite());
        // 执行任务
        env.execute();    
	}
}

